home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
newsgroups
/
misc.20010306-20010921
/
000249_fdc@watsun.cc.columbia.edu_Fri Jul 6 11:33:45 EDT 2001.msg
< prev
next >
Wrap
Text File
|
2001-09-20
|
5KB
|
123 lines
Article: 12574 of comp.protocols.kermit.misc
Path: newsmaster.cc.columbia.edu!watsun.cc.columbia.edu!fdc
From: fdc@watsun.cc.columbia.edu (Frank da Cruz)
Newsgroups: comp.unix.sco.misc,comp.protocols.kermit.misc
Subject: Re: Login Script to Portservers
Date: 6 Jul 2001 15:18:03 GMT
Organization: Columbia University
Lines: 106
Message-ID: <9i4krb$c8u$1@newsmaster.cc.columbia.edu>
References: <4d30cee2.0106290810.737e6c04@posting.google.com> <9hku16$j3a$1@newsmaster.cc.columbia.edu> <Sz617.1532$Tk.35913830@tomcat.sk.sympatico.ca>
NNTP-Posting-Host: watsun.cc.columbia.edu
X-Trace: newsmaster.cc.columbia.edu 994432683 12574 128.59.39.2 (6 Jul 2001 15:18:03 GMT)
X-Complaints-To: postmaster@columbia.edu
NNTP-Posting-Date: 6 Jul 2001 15:18:03 GMT
Xref: newsmaster.cc.columbia.edu comp.unix.sco.misc:135277 comp.protocols.kermit.misc:12574
In article <Sz617.1532$Tk.35913830@tomcat.sk.sympatico.ca>,
Don Yakubowski <don_y@tricomp.ca> wrote:
: "Frank da Cruz" <fdc@watsun.cc.columbia.edu> wrote in message
: news:9hku16$j3a$1@newsmaster.cc.columbia.edu...
: > In article <4d30cee2.0106290810.737e6c04@posting.google.com>,
: > Stephen <stephen.young@duron.com> wrote:
: > : I have two Digi Portservers II attached to a SCO 5.05 host server. I
: > : need to write a login script to a the portservers to reboot them
: > : automatically. In contacting Digi I was told there is no way to set up
: > : an auto reboot on the portserver itself and need to write a login
: > : script to accomplish the task. Any help would be appreciated.
: > :
: > You can use C-Kermit, which is (among other things) a Telnet client with
: > built-in scripting:
: >
: > http://www.columbia.edu/kermit/ckermit.html
: >
: > Scripting tutorials are here:
: >
: > http://www.columbia.edu/kermit/ckscripts.html
:
: I have used a sh script that echoed the required commands to a pipe into
: telnet.
: For eg.
: echo "open your_portserver"
: sleep 2
: echo "root"
: sleep 2
: echo "portserver_password"
: sleep 2
: echo "b a=r"
: sleep 2
:
This kind of thing is fine when it works, but it has no possibility of
detecting errors or recovering from them, synchronizing with host prompts
etc (for example, consider that the Password: prompt is usually issued
only after the host flushes any typeahead in its input buffer). Here's
the corresponding script in C-Kermit:
#!/usr/local/bin/kermit
set host your_portserver ; Make the connection
if fail exit 1 Connection failed ; Check for failure
input 10 login: ; Wait 10 sec for login prompt
if fail exit 1 No login prompt ; Make sure it arrived
lineout root ; Send user ID
input 5 Password: ; Wait 5 sec for Password prompt
lineout portserver_password ; Send password
input 5 > ; Wait portserver command prompt
if fail exit 1 No command prompt ; Check for failure
lineout b a=r ; Send a command
; add more dialog here...
close ; Close the connection
About the same number of lines, and you get both synchroniztion and error
detection. The script does not plow ahead, blindly sending strings to the
host, if some critical step fails. Every prompt is answered instantly
(the timeout values are a maximum amount of time to wait for the prompt --
obviously you can adjust them -- they are not fixed sleep intervals.)
Add a few more lines, and you can get error recovery. For example, suppose
your port server requires an unpredictable number of carriage returns before
it issues its login prompt. Replace:
input 10 login:
if fail exit 1 No login prompt
with:
for \%i 1 15 1 {
lineout ; Send a carriage return
input 10 login: ; Wait 10 sec for login prompt
if success break ; If we get it breat out of the loop
}
if > \%i 15 exit 1 No login prompt
Also note that it's not a great idea to store passwords in script files.
You can have your Kermit script prompt you for the password at runtime:
#!/usr/local/bin/kermit
set host your_portserver
if fail exit 1 Connection failed
undefine \%p
while not defined \%p {
askq \%p {Portserver Password: }
}
for \%i 1 15 1 {
lineout ; Send a carriage return
input 10 login: ; Wait 10 sec for login prompt
if success break ; If we get it breat out of the loop
}
if > \%i 15 exit 1 No login prompt
lineout root
input 5 Password:
lineout \%p
input 5 > ; or whatever the portserver command prompt is
lineout b a=r
; add more dialog here, as much as you want...
close
And so on. Pretty much any way you can think of to enhance the script,
you can do easily. For example, suppose the portserver supports Kermit
protocol (as many do) for importing configuration information, patches, etc.
Since it's Kermit executing your script, all it takes is a "send" command
to upload files.
- Frank